package com.yehongyu.mytools.basic.grammar;

public class Java006_Override extends Java006_OverrideParent {

	private String cannotOverrideNoVisibleMethod() {
		return "Child cannotOverrideNoVisibleMethod";
	}
	
	public static String cannotOverrideStaticMethod() {
		return "Child cannotOverrideStaticMethod";
	}
	
	public String canBeOverrided() {
		return "Child canBeOverrided";
	}
	
	public static void main(String[] args) {
		//测试子类覆盖父类方法
		Java006_OverrideParent obj = new Java006_Override();
		obj.showInvoke();
		Java006_Override objchi = new Java006_Override();
		System.out.println(objchi.cannotOverrideNoVisibleMethod());
	}
}

class Java006_OverrideParent {

	private String cannotOverrideNoVisibleMethod() {
		return "Parent cannotOverrideNoVisibleMethod";
	}
	
	public static String cannotOverrideStaticMethod() {
		return "Parent cannotOverrideStaticMethod";
	}
	
	public String canBeOverrided() {
		return "Parent canBeOverrided";
	}
	
	public void showInvoke() {
		System.out.println(this.getClass().getName());
		System.out.println(this.canBeOverrided());
		System.out.println(this.cannotOverrideNoVisibleMethod());
		//调用静态方法使用类名调用
		System.out.println(Java006_OverrideParent.cannotOverrideStaticMethod());
	}
}
